package com.yoso.shop.infrastructure.constants.commodity;

import cn.hutool.core.collection.CollUtil;
import com.yoso.shop.interfaces.vo.commodity.MasterVo;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * 商品分支
 */
public enum MasterEnum {
    /**
     * 新品系列
     */
    NEW("101", "新品系列"),
    WOMAN("102", "女士"),
    MAN("103", "男士"),
    ART("104", "生活艺术"),
    MAGAZINE("105", "MAGAZINE"),
    HOLIDAY("106", "HOLIDAY");
    private String key;
    private String value;

    MasterEnum(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public String getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }


    public static List<MasterVo> getMasterVoList() {
        List<MasterVo> masterVoList = CollUtil.newArrayList();
        for (MasterEnum e : values()) {
            MasterVo masterVo = MasterVo.builder()
                    .code(e.key)
                    .name(e.value)
                    .build();
            masterVoList.add(masterVo);
        }
        return masterVoList;
    }

    public static Map<String, String> getBothwayMap() {
        Map<String, String> map = new HashMap<>();
        for (MasterEnum e : values()) {
            map.put(e.key, e.value);
            map.put(e.value, e.key);
        }
        return map;
    }

    public static Map<String, String> getSortMap() {
        Map<String, String> map = new LinkedHashMap<>();
        for (MasterEnum e : values()) {
            map.put(e.key, e.value);
        }
        return map;
    }
}

